<include file="default_header"/>
<body>
<div class="wraper">
    <div class="header bg-green">
        <p class="iconfont icon-iconfontuniversity"></p>
        <p>学生注册</p>
        <a href="javascript:history.back(-1)" class="back"><img src="/assets/base/center/images/return.png"/></a>
    </div>
    <div class="container">
        <p class="tips margin-b" style="display: none;">您还可以进行3次自动审核（3次失败后将转为人工审核）</p>
        <div class="form-list margin-b clearfix">
            <span class="field pull-left">学号</span>
            <input class="form-control pull-left" placeholder="请输入您的学号" id="number" value="{BEESCRM:$user['number']}"/>
            <p class="tips-icon">
                <span class="iconfont icon-zhengque icon-green" id="right"></span>
                <span class="iconfont icon-cuowu icon-red" id="wrong"></span>
            </p>
        </div>
        <div class="form-list margin-b clearfix">
            <span class="field pull-left">姓名</span>
            <input class="form-control pull-left" placeholder="请输入您的真实姓名" id="real_name" value="{BEESCRM:$user['real_name']}"/>
            <p class="tips-icon">
                <span class="iconfont icon-zhengque icon-green" id="right"></span>
                <span class="iconfont icon-cuowu icon-red" id="wrong"></span>
            </p>
        </div>
<!--        <div class="form-list margin-b clearfix">
            <span class="field pull-left">短号</span>
            <input class="form-control pull-left" placeholder="请输入您的短号" id="vpmn_mobile" <if condition="$user['vpmn_mobile'] neq 0"> value="{BEESCRM:$user['vpmn_mobile']}" </if>/>
            <p class="tips-icon">
                <span class="iconfont icon-zhengque icon-green" id="right"></span>
                <span class="iconfont icon-cuowu icon-red" id="wrong"></span>
            </p>
        </div>-->
        <div class="form-list margin-b clearfix">
            <span class="field pull-left">手机</span>
            <input class="form-control pull-left" placeholder="请输入您的手机号码" id="mobile" value="{BEESCRM:$user['mobile']}"/>
            <p class="tips-icon">
                <span class="iconfont icon-zhengque icon-green" id="right"></span>
                <span class="iconfont icon-cuowu icon-red" id="wrong"></span>
            </p>
        </div>
        <!--<div class="form-list margin-b">-->
            <!--<input class="form-control" placeholder="请输入验证码" id="smsVerifyCode"/>-->
            <!--<a href="javascript:void(0);" class="btn" id="btn_verify">获取验证码</a>-->
        <!--</div>-->
        <p class="tips validation-tips margin-b"></p>
        <div class="btn-box margin-b">
            <a href="javascript:void(0);" class="btn register">提交</a>
        </div>
        <!--<div class="identity tb-mode">
            <a href="{BEESCRM::U('base/User/register',array('type'=>1,'account_id'=>$accountId))}" class="identity-list">
                <span class="iconfont icon-iconfontlaoshifengcai icon-blue"></span>
                <p>教职工注册</p>
            </a>
            <a href="{BEESCRM::U('base/User/register',array('type'=>2,'account_id'=>$accountId))}" class="identity-list">
                <span class="iconfont icon-iconfontrencopy icon-red"></span>
                <p>来宾注册</p>
            </a>
        </div>-->
    </div>
	<input type="hidden" id="type" value="0">
    <if condition="$remark">
        <include file="remark"/>
    </if>
    <div class="bottom-box">
        <p class="copyright">杭州青橄榄网络技术有限公司 技术支持</p>
    </div>
</div>

<include file="common_js"/>
<script type="text/javascript">
	// 学号验证
	$('#number').bind('input propertychage',function(){
		var number = $(this).val();
		if(number.length < 6){
			notice('#number', 'wrong');
			return false;
		}
	});

    // 点击获取验证码
    var verifyTag = true;
    $('.form-list').on('click', '#btn_verify', function (e) {
        e.preventDefault();
        if(verifyTag) getCode('#btn_verify');
        else return;
    }); 
    
    // 发送验证码
    function getCode(elem) {
    	var data = {};
		data.mobile = $('#mobile').val();
        var verify = /^(?:13\d|15\d|18\d|17\d|14\d)\d{5}(\d{3}|\*{3})$/;
		if (!verify.test(data.mobile)) {
			$.alert('error','请输入正确的手机号码');
        	return false;
		}else{
			var json = {};
            json.url = "{BEESCRM::U('base/User/getCode',array('account_id'=>$accountId))}";
            json.data = data;
            json.method = 'post';
			$.getAjax(json, true, timeCountDown(elem), '');
		}
    }
    
    // 验证倒计时
    function timeCountDown(elem, seconds) {
        verifyTag = false;
        if(typeof seconds == undefined || seconds == null) seconds = 60;
        setTimeout(function () {
            if(seconds > 0) {
                seconds--;
                $(elem).text('已发送 ' + seconds + 's').addClass('disabled');
                timeCountDown(elem, seconds);
            } else {
                $(elem).removeClass('disabled').text('获取验证码');
                verifyTag = true;
            }
        }, 1000);
    }

    $('#mobile').bind('input propertychange', function() {
        var mobile = $("#mobile").val();
        if($.validatePhoneNumber(mobile)){
            $(this).siblings().find('.iconfont').hide();
            $(this).siblings().find('#right').show();
        }else{
            $(this).siblings().find('.iconfont').hide();
            $(this).siblings().find('#wrong').show();
        }
    });


    var height = $(window).height();
    var bottombox_height = $('.bottom-box').outerHeight();
    $('.wraper').css("minHeight", height);
    $('.wraper').css("paddingBottom", bottombox_height);

	// 验证提示
	function notice(elem, class_name){
		$(elem).siblings().find('.iconfont').hide();
		$(elem).siblings().find('#' + class_name).show();
	}

	$(document).on('click','.register',function(){
		var data = {};
		var verify_method = /^(?:13\d|15\d|18\d|17\d|14\d)\d{5}(\d{3}|\*{3})$/;
		data.number = $('#number').val();
		data.real_name = $('#real_name').val();
//		data.vpmn_mobile = $('#vpmn_mobile').val();
		data.mobile = $('#mobile').val();
		data.smsVerifyCode = $('#smsVerifyCode').val();
		data.type = $('#type').val();
        
		if (!data.number || data.number.length > 15) {
            $('.validation-tips').html('请输入正确的学号').show();
			return false;
		} else if (!data.real_name) {
			$('.validation-tips').html('姓名不能为空').show();
			return false;
		} else if(!data.mobile){
			$('.validation-tips').html('手机号不能为空').show();
			return false;
		}else if (!verify_method.test(data.mobile)) {
			$('.validation-tips').html('请输入正确的手机号').show();
			return false;
		}

		var json = {};
		json.method = 'post';
		json.type = 'json';
		json.url = "{BEESCRM::U('/base/User/doRegister',array('account_id'=>$accountId ,'type' => 0))}";
		json.data = data;
		$.getAjax(json, true, reload, '');
		
	});
	function reload(data){
		var type = data.type;
		location.href="{BEESCRM::U('/base/User/tips',array('account_id'=>$accountId))}/type/"+type;
		//setTimeout("location.href ='{BEESCRM::U('base/center/center',array('wechat_id'=>$wechat_id))}'", 2000);
	}
</script>
</body>
</html>